In [24]:
using Base.Test
In [170]:
include("../src/utils.jl")
Out[170]:
In [172]:
k = 2
N = 100
alpha = 1.0
gamma_a = 1.0
gamma_b = 1.0
alpha = random_concentration_parameter!(alpha, gamma_a, gamma_b, N, k, maxiter = 10)
@test alpha < 1.0
@test alpha > 0.0
In [174]:
random_concentration_parameter(alpha, gamma_a, gamma_b, N, k, maxiter = 10)
@time random_concentration_parameter(alpha, gamma_a, gamma_b, N, k, maxiter = 10)
Out[174]:
In [175]:
k = [2 4]
N = [100 100]
alpha = 1.0
gamma_a = 1.0
gamma_b = 1.0
alpha = random_concentration_parameter(alpha, gamma_a, gamma_b, N, k, maxiter = 10)
@test alpha < 1.0
@test alpha > 0.0
In [177]:
random_concentration_parameter(alpha, gamma_a, gamma_b, N, k, maxiter = 10)
@time random_concentration_parameter(alpha, gamma_a, gamma_b, N, k, maxiter = 10)
Out[177]:
In [179]:
p = [0.1 0.7 0.2]
pp = [0 0 0]
for j = 1:10000
pp[rand_indices(p)] += 1
end
pp /= 10000
@test_approx_eq_eps pp[1] p[1] 0.01
@test_approx_eq_eps pp[2] p[2] 0.01
@test_approx_eq_eps pp[3] p[3] 0.01
In [180]:
for j = 1:10000
rand_indices(p)
end
@time for j = 1:10000
rand_indices(p)
end
Out[180]: